package com.huiying.mapper;


import com.huiying.entity.entity.Tag;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: lsh
 * @Date: 2024/11/09/14:21
 * @Description: 标签数据访问类
 */
@Mapper
public interface TagMapper {

    /**
     *  查询标签列表
     * @return: java.util.List<com.fx.entity.Tag>
     */
    @Select("select id, name from tags")
    List<Tag> getTags();

    @Select("select t.id as id, t.name as name " +
            "from contenttags ct " +
            "join tags t on ct.tags_id = t.id " +
            "where ct.content_id = #{demandId} " +
            "and ct.content_type = #{contentType}")
    List<Tag> getTagsByDemandId(Long demandId,String contentType);

    @Delete("delete from contenttags where content_id = #{id} and content_type = #{demand}")
    void deleteByContentId(@Param("id") Long id, @Param("demand") String demand);
}
